Skip to content

Grid3DView's Strata calls covered by tests against a fake binding - #81

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/grid3d-view-engine-tests
Nov 20, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feature/grid3d-view-engine-tests

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B (unit-test expansion) cycle, targeting grid3d/view.py, the least-covered module in the package.

  • grid3d/view.py was at 37% line coverage. Everything past loadStrata's first two checks was reached only by the two render tests, which skip wherever the Strata library cannot load. That includes CI, so in practice open, drawScene, pollEvents, resize, savePng and close were never run.
  • A fake strata module (a recording FakeEngine, plus the constants and record constructors view.py uses) is installed through monkeypatch.setitem(sys.modules, ...). With it, 13 new tests drive the real Grid3DView code with no GPU:
    • loadStrata: the pinned load_release(STRATA_VERSION); STRATA_LIBRARY choosing load() on any platform; a load failure wrapped as Unavailable with its reason
    • open: the windowed versus headless surface and title, the sun lighting setup, and an engine constructor failure wrapped as Unavailable
    • the setBoard()-first guards on setPieces, scene and camera, plus pickCell returning None without a board
    • geometry delegation: a cell's screen position picks the same cell back
    • frame / drawScene: the engine call order, the camera aspect, point-light shadow flags, panels and labels (UTF-8 text), skipping empty panels, labels and camera, present=False, and a scene over the engine limits being refused before any engine call
    • pollEvents draining the queue, resize, savePng, and a second close doing nothing
  • view.py coverage goes from 37% to 100%. Total coverage goes from 90% to about 97%.
  • These are characterization tests: no production code changed, and no bug was found.

Test plan

  • SDL_VIDEODRIVER=dummy python3 -m pytest: 303 passed, 2 skipped (the two Strata render tests, as on main). The baseline was 291 passed.
  • pytest --cov=preponderous.graphik.grid3d.view: 100%
  • Every environment variable the tests touch (GALLIUM_DRIVER, SDL_VIDEODRIVER, STRATA_LIBRARY), plus sys.platform and sys.modules['strata'], is set through monkeypatch, so each one is restored after the test
  • CI Test workflow green

Deferred issues

All six open issues were skipped this cycle:

No tracking issue: the coverage gap was found during triage.

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

grid3d/view.py was 37% covered: everything past loadStrata's first two
checks only ran in the render tests, which skip wherever Strata can't
load (including CI). The view is now driven against a fake `strata`
module, so opening, loading, drawing a Scene, events, resize and close
are exercised on every run. view.py coverage goes from 37% to 100%.
Tests only; no production code changed.

drafted by Claude on behalf of Daniel Stephenson

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (single intrinsic pass, anchored on local pytest and CI):

  • Scope: PASS. git diff --name-only origin/main...HEAD lists only src/test/python/preponderous/graphik/grid3d/test_grid3d_view.py, with +232/−2 lines, all test code.
  • Tests-new: PASS (not applicable). No new public method was added.
  • Tests-fix: not applicable. No bug fix; these are characterization tests and no production code changed.
  • Sibling structure: PASS. The new tests sit in their own # -- ... section between the existing "why it can't start" and "rendering" sections. Test names follow the file's sentence-style test_a_..._is_... naming, and the module docstring was extended to describe the new section.
  • Sibling renames: not applicable. Nothing was renamed.
  • Docs: PASS. No behaviour changed, so README, RELEASING.md and the view.py docstrings remain accurate.
  • Issue resolution: not applicable. No Closes; the coverage gap was found during triage.
  • Manual validation: PASS. Locally py_compile succeeded and pytest ran 303 passed, 2 skipped (baseline 291 passed). CI's Compile and test passed on 3.9–3.13, and Install from a release archive passed.
  • camelCase / Backward-compat / Version sync / No new deps: PASS. No public surface, version string or import in production code was touched. The tests add only the stdlib types import.
  • Headless: PASS. No test opens a real engine, since every new test runs against the fake strata module. SDL_VIDEODRIVER and GALLIUM_DRIVER are set through monkeypatch, so neither leaks to later tests.

Judgment notes (not blocking):

  • src/test/python/preponderous/graphik/grid3d/test_grid3d_view.py, FakeEngine.__getattr__: the fake accepts any method name, so a misspelled engine call in view.py would be recorded rather than raise. This is mitigated by test_a_frame_draws_the_scene_through_the_engine and the no-camera test, which assert the exact sequence of engine method names, so a renamed call fails there.
  • src/test/python/preponderous/graphik/grid3d/test_grid3d_view.py, fakeStrata: the fake models the binding as view.py uses it, not the real strata-engine API. Drift in the real binding (for example a renamed constant in a future Strata release) is still caught only by the two render tests, which skip in CI. These tests guard view.py's own logic, not binding compatibility.

The change is ready to merge: tests only, CI green, and no do-not-auto-merge path touched.

This review comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit b7e3ee5 into main Nov 20, 2026
6 checks passed
@dmccoystephenson
dmccoystephenson deleted the feature/grid3d-view-engine-tests branch November 20, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant